import unittest

import psutil

def find_process_by_cmd(name: str):
    proc_list = []
    for proc in psutil.process_iter():
        if name in ' '.join(proc.cmdline()):
            proc_list.append(proc)
    return proc_list


class UtilsTest(unittest.TestCase):
    def test_find_process_by_name(self):
        self.assertTrue(find_process_by_cmd('eye_protector.py') is None)
        self.assertTrue(find_process_by_cmd('redis') is not None)


if __name__ == '__main__':
    unittest.main()